import 'package:flutter/material.dart';
import '../model/search_model.dart';

class TitleView extends StatefulWidget {
  final SessionCoinModel sessionModel;
  final VoidCallback callBack;
  TitleView(this.sessionModel,this.callBack);

  @override
  TitleViewState createState() => TitleViewState();
}

class TitleViewState extends State<TitleView> {
  @override
  Widget build(BuildContext context) {
    return _titleView(context);
  }

  Widget _titleView(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 10),
      child: ClipRRect(
        borderRadius: BorderRadius.vertical(top: Radius.circular(10.0)),
        child: Container(
          height: 35,
//          color: color(0xeaeaea),
          color: Color(0xffeaeaea),
          child: Row(
            children: <Widget>[
              _title(),
              _middle(),
              _arrow(),
            ],
          ),
        ),
      ),
    );
  }

  Widget _title(){
    return Container(
      margin: EdgeInsets.only(left: 10),
      child: Text("${widget.sessionModel.title}",style: TextStyle(color: Colors.black54,fontSize: 12)),
    );
  }

  Widget _middle(){
    return Flexible(
        child: Container(
          height: 35,
        )
    );
  }

  Widget _arrow(){
    return IconButton(
        icon: widget.sessionModel.isOpen ? Icon(Icons.keyboard_arrow_down) : Icon(Icons.keyboard_arrow_up),
        onPressed: (){
          setState((){
            widget.sessionModel.isOpen = !widget.sessionModel.isOpen;
          });
          if(widget.callBack != null) {
            widget.callBack();
          }
        }
    );
  }
}